import behaviors from "../../../../config/behaviors";

Component({
  behaviors: [behaviors],
  properties: {
    list: {
      type: Array,
      default: []
    }
  },
  data: {},
  methods: {
    handleClick(event) {
      const item = event.currentTarget.dataset.item
      if (item && item.url && item.url.length > 1) {
        console.log(item.url.indexOf('switchTab'))
        if (item.url.indexOf('switchTab') !== -1) {
          const url = item.url.replace('switchTab', '')
          console.log(url)
          wx.switchTab({
            url
          })
        } else if (item.url === '/category') {
          wx.switchTab({
            url: '/pages/category/index'
          })
        } else {
          wx.navigateTo({
            url: item.url
          })
        }
      }
    }
  }
});
